#include <stdio.h>  
#include <stdlib.h>  
#include <sys/types.h>  
#include <sys/stat.h>

#include "od_errno.h"
#include "od_sip_info.h"
#include "od_trace.h"

#define OD_SIP_INFO_PICT_FAST_UPDATE  "picture_fast_update"
#define CONTENT_KEYFRAME_XML          "application/media_control+xml"

void *od_sip_info_is_keyframe_request(eXosip_t *ex_ctx, eXosip_event_t *event)
{
    osip_body_t *body = NULL;
    osip_content_type_t *content_type = NULL;
    char con_type[64] = {0}; //content type in one string */* stile
    
    OD_SIP_ASSERT_RETURN(ex_ctx && event, NULL);

    content_type = osip_message_get_content_type(event->request);
    if (!content_type) {
        RPTERR("get content_type Header error!!");
        return NULL;
    }

    if (content_type->type && content_type->subtype)
        snprintf(con_type, sizeof(con_type), "%s/%s", content_type->type, content_type->subtype);
    
    if (strcasecmp(CONTENT_KEYFRAME_XML, con_type)){
        RPTERR("unknown content_type Header!!! should be:[%s], but offer is:[%s]",
            CONTENT_KEYFRAME_XML, con_type);
        return NULL;
    }

    if(osip_message_get_body(event->request, 0, &body) < 0)
    {
        RPTERR("osip_message_get_body, error!!");
        return NULL;
    }

    if (body->body)
        return strstr(body->body, OD_SIP_INFO_PICT_FAST_UPDATE);   
    else
        return NULL;
}

/*_*/

